---
layout: "default"
title: "unsafeDowncast"
description: "Swift documentation for 'unsafeDowncast': Returns: x as T."
keywords: "unsafeDowncast,func,swift,documentation"
root: "/v1.2"
---

<div class="declaration" id="func-unsafedowncast-t_-anyobject">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-unsafedowncast-t_-anyobject">func unsafeDowncast&lt;T&gt;(<wbr>_: AnyObject)</a>
        
<div class="comment collapse" id="comment-func-unsafedowncast-t_-anyobject"><div class="p">
    <p>Returns: <code>x as T</code></p>

<p>Requires: <code>x is T</code>.  In particular, in -O builds, no test is
performed to ensure that <code>x</code> actually has dynamic type <code>T</code>.</p>

<p><strong>Danger:</strong> trades safety for performance.  Use <code>unsafeDowncast</code>
  only when <code>x as T</code> has proven to be a performance problem and you
  are confident that, always, <code>x is T</code>.  It is better than an
  <code>unsafeBitCast</code> because it&#39;s more restrictive, and because
  checking is still performed in debug builds.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func unsafeDowncast&lt;T&gt;(x: AnyObject) -&gt; T</code>
    
    
</div></div>
</div>
